module App::View
    class TogglTree < Qt::TreeView
        slots 'itemChanged(QStandardItem*)'
        slots 'modelColumnsModified()'

        def initialize()
            super()

            self.all_columns_show_focus = true
            self.expands_on_double_click = false
            self.auto_expand_delay = 500
            self.alternating_row_colors = true
            self.accept_drops = true
            self.context_menu_policy = Qt::CustomContextMenu
            #setAllColumnsShowFocus true
            #setExpandsOnDoubleClick false
            #setAutoExpandDelay 500
            #setAlternatingRowColors true
            #setAcceptDrops true  # muszaj globalisan
            #setContextMenuPolicy Qt::CustomContextMenu
            #
            # XXX igy nem mukodik a popup menu
            #setSelectionMode Qt::AbstractItemView::NoSelection
        end

        private
        def itemChanged(item)
            #p "itemChanged", item
            return unless item.is_a? App::Items::Task

            font = viewOptions.font
            #font = Qt::Application::font
            font.setBold false
            font.setBold true if item.started
            #for i in 0...midx.model.columnCount
                #item = midx.model.item(midx.row, i)
                item.setFont font
            #end
        end

        def modelColumnsModified()
            # Should I save it..?
            setColumnWidth 0, 220
            setColumnWidth 1, 70
            setColumnWidth 2, 70
            setColumnWidth 3, 45
        end
    end
end
